import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'dart:async';
import 'dart:async';
import 'dart:async';

class BottomSheetDemo extends StatefulWidget {
  @override
  _BottomSheetDemoState createState() => _BottomSheetDemoState();
}

enum Action { A, B, C }

class _BottomSheetDemoState extends State<BottomSheetDemo> {
  final _bottomSheetScaffoldKey = GlobalKey<ScaffoldState>();
  String _chiose = 'n';

  _openmodal() async {
    final option = await showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return Container(
            height: 200,
            child: Column(
              children: [
                ListTile(
                  title: Text('A'),
                  onTap: () => Navigator.pop(context, Action.A),
                ),
                ListTile(
                  title: Text('B'),
                  onTap: () => Navigator.pop(context, Action.B),
                ),
                ListTile(
                  onTap: () => Navigator.pop(context, Action.C),
                  title: Text('C'),
                ),
              ],
            ),
          );
        });
    switch (option) {
      case Action.A:
        setState(() {
          _chiose = 'A';
        });
        break;
      case Action.B:
        setState(() {
          _chiose = 'B';
        });
        break;
      case Action.C:
        setState(() {
          _chiose = 'C';
        });
        break;
    }
    print(option);
  }

  _open() {
    _bottomSheetScaffoldKey.currentState
        ?.showBottomSheet((BuildContext context) {
      return BottomAppBar(
        child: Container(
          height: 90,
          width: double.infinity,
          padding: EdgeInsets.all(10),
          child: Row(
            children: [
              Icon(Icons.pause_circle_filled),
              SizedBox(
                width: 130,
              ),
              Text('1010'),
              Expanded(
                  child: Text(
                'coldplay',
                textAlign: TextAlign.right,
              ))
            ],
          ),
        ),
      );
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _bottomSheetScaffoldKey,
      appBar: AppBar(
        title: Text('BottomSheetDemo'),
        elevation: 0,
      ),
      body: Container(
        padding: EdgeInsets.all(16),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('data$_chiose'),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ElevatedButton(
                  onPressed: _open,
                  child: Text(
                    'button',
                  ),
                ),
                ElevatedButton(
                  onPressed: _openmodal,
                  child: Text(
                    'modalbutton',
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
